package com.andong.controller;

import com.andong.domain.dto.LoginDTO;
import com.andong.domain.pojo.Result;
import com.andong.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * ClassName: LoginController
 * 登录请求处理类
 * @author XHU_WHY
 * @version V1.0
 * @since 2024/1/2 19:46
 */
@RestController
@Slf4j
@RequestMapping("/login")
public class LoginController {
    @Resource
    LoginService loginService;

    @PostMapping("/username")
    public Result loginByUsername(@RequestBody LoginDTO loginDTO) throws Exception {
        return loginService.loginByUsername(loginDTO);
    }

    @PostMapping("/sms")
    public Result loginBySMS(@RequestBody LoginDTO loginDTO) {
        // 调用service层代码
        return loginService.loginBySMS(loginDTO);
    }

    @GetMapping("/getCode")
    public Result getCode(String phone) throws Exception {
        // 调用service层方法
        return loginService.getCode(phone);
    }
}
